<?php
// +-------------------------------------------------------------------
// | 
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Kcdns\Admin\Controller;

/**
 * 管理员
 */
class MemberController extends CommonController
{

    protected function _initialize ()
    {
        parent::_initialize();
       /* $this->listWhere = [
                'member.uid' => [
                        'neq',
                        C('USER_ADMINISTRATOR')
                ]
        ];*/
    }

    public function add(){


        if (IS_POST) {
            try {
                if (strlen(I('post.member.password'))<8) {
                    throw new \Exception("密码至少需要8位");
                }
            }catch (\Exception $e) {
                $this->error($e->getMessage());
            }
        }

        parent::add();
    }

    public function edit(){
        parent::edit();
    }

    public function del ()
    {
        $this->listWhere = [];
        parent::del();
    }
    
    // 修改当前用户密码
    public function password ()
    {
        IS_POST and $this->modelAction = 'editPassword';
        $this->listWhere = [
                'member.uid' => UID
        ];
        return parent::edit();
    }
    
    // 修改用户所属分组
    public function group ()
    {
        $this->modelAction = IS_POST ? 'updateGroup' : 'getDataGroup';
        return parent::edit();
    }
}